// ActionScript file
			import mx.collections.ArrayCollection;
			import mx.rpc.events.ResultEvent;
			[Bindable] private var drarr:ArrayCollection = new ArrayCollection;
			[Bindable] private var drugnam:ArrayCollection = new ArrayCollection;
	    	[Bindable] private var bno:int = new int;
			[Bindable] private var billdgarray:ArrayCollection = new ArrayCollection;
			[Bindable] private var ppu:ArrayCollection = new ArrayCollection;
			[Bindable] private var gtotal:int=0;
			private function resHandler(event:ResultEvent):void{
				drarr = event.result.billdata.name as ArrayCollection;
				drugnam = event.result.billdata.drugname as ArrayCollection;
				billno.text=event.result.billdata.maxbillno+1;
				adddrug.dataProvider = event.result.billdata.drugname as ArrayCollection;
				ppu = event.result.billdata.ppu as ArrayCollection;
				//Alert.show(ppu.length.toString());
			}
			private function updateDatagridArray():void{
				var temparr:Array = new Array;
				temparr.push(billdgarray.length+1);
				temparr.push(adddrug.selectedItem);
				temparr.push(uqty.text);
				temparr.push(uppu.text);
				temparr.push(utotal.text);
				billdgarray.addItem(temparr);
				billdata.send();
				adddrug.selectedIndex=0;
				uppu.text = ppu[adddrug.selectedIndex];
				//uqty.text = "qty";
				//var k:Number=0;
				for(var i:Number = 0;i<billdgarray.length;i++){
					
					gtotal= gtotal+int(billdgarray[i][4]); 
				}
			}
			private function resetbill():void{
				billdgarray.removeAll();
				gtotal=0;
			}
			private function poparritem():void{
				billdgarray.removeItemAt(billdgarray.length-1);
				gtotal = 0;
				for(var i:Number = 0;i<billdgarray.length;i++){
					gtotal= gtotal+int(billdgarray[i][4]); 
				}
			}
			private function getpricedetails():void{
				uppu.text = ppu[adddrug.selectedIndex];
			}
			private function finish():void{
			 	insertItem();
				gateway.disconnect();
			 	insertItems();
				billchildgen.disconnect();
				doPrint();
			}
			//print overview--------------------------------
            import mx.printing.FlexPrintJob;
            import myComponents.MyPrintView;
            public function doPrint():void {
                // Create a FlexPrintJob instance.
                var printJob:FlexPrintJob = new FlexPrintJob();
                // Start the print job.
                if(printJob.start()) {
                    var formPrintView:MyPrintView = new MyPrintView();
                    addChild(formPrintView);
                    formPrintView.patientName.text = "Patient Name : "+patientname.text;
                    formPrintView.gender.text = "Gender :"+ gender.selectedLabel;
                    formPrintView.date.text = "Date"+dat.text;
                    formPrintView.billno.text = " Bill No : "+ billno.text;
                    formPrintView.refdr.text=" Referal Dr : "+refdr.text;
                    formPrintView.dgrid.dataProvider = billdg.dataProvider;
                    formPrintView.gtotal.text = "Grand Total:"+gt0.text;
                    printJob.addObject(formPrintView);
                    printJob.send();
                    removeChild(formPrintView);
                }
            }